import React from 'react';
import { Table } from 'antd';
import Page from 'components/common/Page';
import { model } from 'utils/model';
import SearchBar from './SearchBar';
import fields from './fields';

@model('equipData')
class UserManage extends React.Component {
  constructor(props) {
    super(props);
    this.timer = null;
    this.state = {
      visible: false,
      myChart: null,
      monitorData: props.monitorData || {}
    };
  }

  componentDidMount() {
    // var myChart = echarts.init(document.getElementById('main'));
    // this.setState({ myChart });
  }
//   componentWillReceiveProps(next){
//     //   const { myChart } = this.state;
//     //   if(next.monitorData !== this.props.monitorData){
//     //       const option = initOption(next.monitorData);
//     //       myChart.setOption(option);
//     //   }
//   }
// 扩展字段
extraFields() {
    const extra = [];
    return fields.concat(extra);
  }
  
  render() {
    const { 
        search,
        config,
        goPage,
        getList,
        loading,
        equipList,
        getEquipList,
        templateList,
        updateSearch,
        queryDataTemplateItems
    } = this.props;
    const searchProps = {
        search,
        equipList,
        getEquipList,
        templateList,
        queryDataTemplateItems,
        onSearch: (params) => {
            updateSearch(params);
            getList(params);
        }
    };
    const { pagination, list } = config;
    const tableProps = {
        pagination: {
          ...pagination,
          onChange: (current) => {
            goPage(current);
            getList();
          }
        },
        // scroll: {
        //     x: 1600
        // },
        loading: loading.list,
        rowKey: (record, index) => index,
        dataSource: list,
        columns: this.extraFields()
      };
    return (
      <Page inner>
        <div>
          <SearchBar {...searchProps} />
          <Table {...tableProps} style={{marginTop: 20}} />
        </div>
      </Page>
    );
  }
}


export default UserManage;
